package com.chuangyiruanke.util;

import java.util.List;


/**
 * 分页封装类
 * 用于做分页查询的基础类，封装了一些分页的相关属性
 *
 * @param <T>
 * @version v1.0
 */
public class PageResult<T> extends RequestResult<List<T>> {
    private static final int defaultLimit = 10;
    // 当前页
    private final int limit;
    // 每页个数
    private final long skip;
    // 总条数
    private long total;

    public int getLimit() {
        return limit;
    }

    public long getSkip() {
        return skip;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public PageResult() {
        this(defaultLimit, 0L);
    }

    public PageResult(Integer limit) {
        this(limit, 0L);
    }

    public PageResult(Integer limit, Long skip) {
        this.limit = limit == null ? defaultLimit : limit;
        this.skip = skip == null ? 0 : skip;
    }

    public PageResult(PageResult<?> other) {
        this(other.getLimit(), other.getSkip());
        this.total = other.getTotal();
    }
}


